Chapter 5 LAGOS Spatial Analysis

5.1 Loading in data

5.1.1 First download and then specifically grab the locus (or site lat longs)

# #Lagos download script
#LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())


#Load in lagos
lagos <- lagosne_load()
## Warning in (function (version = NULL, fpath = NA) : LAGOSNE version unspecified,
## loading version: 1.087.3
#Grab the lake centroid info
lake_centers <- lagos$locus

5.1.2 Convert to spatial data

#Look at the column names
#names(lake_centers)

#Look at the structure
#str(lake_centers)

#View the full dataset
#View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'), crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100) 

subset_baser <- spatial_lakes[1:100,]

#Dynamic mapviewer
mapview(subset_spatial)

5.1.3 Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)


#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]

#Plotting the first 1000 lakes
minnesota_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha') + mapview(minnesota)

5.2 In-Class work

5.3 1 Map of Iowa & Illinois

Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

#Plot all the states to check if they loaded
#mapview(states)
iowa <- states %>%
  filter(name == 'Iowa') %>%
  st_transform(2163)

illinois <- states %>%
  filter(name == 'Illinois') %>%
  st_transform(2163)

mapview(illinois, alpha.regions = 0.4, aplha = 1, col.regions = "yellow") + 
mapview(iowa, alpha.regions = 0.4, aplha = 1, col.regions = "red")
#Subset lakes based on spatial position
iowa_lakes <- spatial_lakes[iowa,]

#Plotting the first 1000 lakes
mapview(iowa, alpha.regions = 0.4, aplha = 1, col.regions = "red") +
  iowa_lakes %>%
  arrange(-lake_area_ha) %>%
  slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')
#Subset lakes based on spatial position
illinois_lakes <- spatial_lakes[illinois,]

#Plotting the first 1000 lakes
mapview(illinois, alpha.regions = 0.4, aplha = 1, col.regions = "yellow") +
  illinois_lakes %>%
  arrange(-lake_area_ha) %>%
  slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

5.4 2 Subset LAGOS data

Subset LAGOS data to these sites, how many sites are in Illinois and Iowa combined? How does this compare to Minnesota?

minnesota_length = length(minnesota_lakes$lagoslakeid)
iowa_illinois_lakes = rbind(illinois_lakes, iowa_lakes)
iowa_illinois_length = length(iowa_illinois_lakes$lagoslakeid)

Minnesota has 29038 lakes while Iowa & Illinois combined have 16466 lakes

5.5 3 What is the distribution of lake size in Iowa vs. Minnesota?

Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)

ggplot(minnesota_lakes, aes(x= lake_area_ha)) + 
  geom_histogram() + 
  scale_x_log10(labels = scales::comma) +
  labs(title="Minnesota Lakes")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(iowa_lakes, aes(x= lake_area_ha)) + 
  geom_histogram() + 
  scale_x_log10(labels = scales::comma) +
  labs(title="Minnesota Lakes")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Minnesota has bigger lakes than Iowa. Both are skewed to the right.

5.6 4 Lakes in Iowa & Illinois by lake area

Make an interactive plot of lakes in Iowa and Illinois and color them by lake area in hectares

iowa_illinois_map = iowa_illinois_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha',  canvas = TRUE, at=c(0,10,100,1000,10000)) 

mapview(illinois,  canvas = TRUE , alpha.regions = 0.4, aplha = 1, col.regions = "yellow") + 
  mapview(iowa,  canvas = TRUE , alpha.regions = 0.4, aplha = 1, col.regions = "red") +
  iowa_illinois_map 

5.7 5 What other data sources might we use to understand how reservoirs and natural lakes vary in size in these three states?

Ground water & especially water table depth data would be helpful for looking at how the lakes interact with one another. Long term weather & climate (rainfall, snowfall, and Total Solar Radiance) would be helpful in to for understanding water origin & evaporation.